@echo off

if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" goto :msvc64-10
if exist "%ProgramFiles%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" goto :msvc86-10

if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" goto :msvc64-11
if exist "%ProgramFiles%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" goto :msvc86-11

goto :eof

:msvc64-10

call "%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x64

goto :msvc

:msvc86-10

call "%ProgramFiles%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x64

goto :msvc

:msvc64-11

call "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x64

goto :msvc

:msvc86-11

call "%ProgramFiles%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x64

goto :msvc

:msvc

cd src\pattern\pcre

if exist pcre_chartables.c del pcre_chartables.c
if exist dftables.c cl /w dftables.c
if exist dftables.exe dftables.exe pcre_chartables.c
if exist dftables.exe del dftables.exe
if exist dftables.obj del dftables.obj

cd ..\..\..

cl /Ox /Ot /GL /MP /D _CRT_SECURE_NO_WARNINGS src/pattern/ProcPat.c src/pattern/51Degrees.mobi.c src/pattern/pcre/pcre_chartables.c src/pattern/pcre/pcre_compile.c src/pattern/pcre/pcre_config.c src/pattern/pcre/pcre_dfa_exec.c src/pattern/pcre/pcre_exec.c src/pattern/pcre/pcre_fullinfo.c src/pattern/pcre/pcre_get.c src/pattern/pcre/pcre_globals.c src/pattern/pcre/pcre_info.c src/pattern/pcre/pcre_maketables.c src/pattern/pcre/pcre_newline.c src/pattern/pcre/pcre_ord2utf8.c src/pattern/pcre/pcre_refcount.c src/pattern/pcre/pcre_study.c src/pattern/pcre/pcre_tables.c src/pattern/pcre/pcre_try_flipped.c src/pattern/pcre/pcre_ucp_searchfuncs.c src/pattern/pcre/pcre_valid_utf8.c src/pattern/pcre/pcre_version.c src/pattern/pcre/pcre_xclass.c src/pattern/pcre/pcreposix.c src/pattern/snprintf/snprintf.c
cl /Ox /Ot /GL /MP /D _CRT_SECURE_NO_WARNINGS src/pattern/PerfPat.c src/pattern/51Degrees.mobi.c src/pattern/pcre/pcre_chartables.c src/pattern/pcre/pcre_compile.c src/pattern/pcre/pcre_config.c src/pattern/pcre/pcre_dfa_exec.c src/pattern/pcre/pcre_exec.c src/pattern/pcre/pcre_fullinfo.c src/pattern/pcre/pcre_get.c src/pattern/pcre/pcre_globals.c src/pattern/pcre/pcre_info.c src/pattern/pcre/pcre_maketables.c src/pattern/pcre/pcre_newline.c src/pattern/pcre/pcre_ord2utf8.c src/pattern/pcre/pcre_refcount.c src/pattern/pcre/pcre_study.c src/pattern/pcre/pcre_tables.c src/pattern/pcre/pcre_try_flipped.c src/pattern/pcre/pcre_ucp_searchfuncs.c src/pattern/pcre/pcre_valid_utf8.c src/pattern/pcre/pcre_version.c src/pattern/pcre/pcre_xclass.c src/pattern/pcre/pcreposix.c src/pattern/snprintf/snprintf.c
cl /Ox /Ot /GL /MP /D _CRT_SECURE_NO_WARNINGS src/trie/ProcTrie.c src/trie/51Degrees.mobi.c src/trie/snprintf/snprintf.c
cl /Ox /Ot /GL /MP /D _CRT_SECURE_NO_WARNINGS src/trie/PerfTrie.c src/trie/51Degrees.mobi.c src/trie/snprintf/snprintf.c

del *.obj

goto :eof

:eof
